﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

/*
 * ArCamera 统一控制 Btn 点击事件
 */
public class BtnClickController : MonoBehaviour
{
    private Button mBtnCheckArCore;
    private Button mBtnInstallArCoreApk;
    private ApkManager mApkManagerComponent;

    private void Awake()
    {
        mBtnCheckArCore = (Button)GameObject.Find("Canvas/BtnCheckArCore").GetComponent<Button>();
        GameObject objBtnInstallArCoreApk = GameObject.Find("Canvas/BtnInstallArCoreApk");
        mBtnInstallArCoreApk = (Button)objBtnInstallArCoreApk.GetComponent<Button>();
        mApkManagerComponent = objBtnInstallArCoreApk.GetComponent<ApkManager>();
    }

    // Start is called before the first frame update
    void Start()
    {
        mBtnCheckArCore.onClick.AddListener(OnCheckArCoreBtnClick);
        mBtnInstallArCoreApk.onClick.AddListener(OnInstallArCoreApkBtnClick);
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void OnCheckArCoreBtnClick()
    {
        IEnumerator result = CheckArUtils.CheckArSupport();
        ToastUtil.showToast("BtnClickController OnCheckArCoreBtnClick() CheckArSupport() result=" + result);
    }

    public void OnInstallArCoreApkBtnClick()
    {
        mApkManagerComponent.InstallAPK();
        ToastUtil.showToast("BtnClickController OnInstallArCoreApkBtnClick()");
    }
}
